package com.cn.por.biz.vue.controller;

import cn.hsa.base.web.vo.PageResultData;
import cn.hsa.base.web.vo.WrapperResponse;
import com.cn.por.util.html.ElementUiApi;
import com.cn.por.util.html.ModelApi;
import com.cn.por.util.html.SwaggerParseUtil;
import com.cn.por.util.pageUtils.PageUtilCustom;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/web/vue")
@Api(tags="获取api信息")
public class VueCodeGenaController {


    @PostMapping("/getApi")
    @ApiOperation("获取api分页信息")
    public WrapperResponse<PageResultData<ElementUiApi>> getApi(@RequestParam int pageNo,
                                                            @RequestParam int pageSize,
                                                            @RequestBody Map<String,String> param){

        String url = param.get("url");
        String id = param.get("id");
        String name = param.get("name");
        List<ModelApi> modelApis = SwaggerParseUtil.parseSwagger(url, id, name);
        List<ElementUiApi> elementUiApi = SwaggerParseUtil.getElementUiApi(modelApis);
        PageResultData<ElementUiApi> pageDto = PageUtilCustom.getPageDto(elementUiApi, pageNo, pageSize);
        return WrapperResponse.success(pageDto);
    }
}
